package com.pashanhoo.datastructure.leetcode;

/**
 * @author 胡庆安
 * @version V1.0
 * @Package com.pashanhoo.datastructure.leetcode
 * @date 2020/10/16 16:43
 * @Copyright © 2010-2020 爬山虎科技（扬州）股份有限公司
 */
public class Test1 {
    public static void main(String[] args) {
        int[] ints = {-4,-1,0,3,10};
        int[] sort = sortedSquares(ints);
        System.out.println(sort);
    }

    public static int[] sortedSquares(int[] A) {
        for (int i=0;i<A.length;i++){
            for(int j=i+1;j<A.length;j++){
                if (A[i]>A[j]){  //寻找最大的数
                    int temp = A[i];
                    A[i] = A[j];
                    A[j] = temp;
                }
            }
        }
        for(int i=0;i<A.length;i++){
            A[i] = A[i] * A[i];
        }
        return A;
    }
}
